package cn.meibang.common.beauty.provider.dao;

import cn.apestar.core.database.BaseMapper;
import cn.meibang.common.beauty.provider.domain.BeautyConsultationOrderRecommendDetail;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

public interface BeautyConsultationOrderRecommendDetailMapper extends BaseMapper {
    @Delete({
            "delete from beauty_consultation_order_recommend_detail",
            "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
            "insert into beauty_consultation_order_recommend_detail (id, order_id, ",
            "answer_id, recommend_id, ",
            "recommend_type, product_id, ",
            "product_name, create_by, ",
            "create_date, update_by, ",
            "update_date, remarks, ",
            "del_flag, institution_id)",
            "values (#{id,jdbcType=BIGINT}, #{orderId,jdbcType=BIGINT}, ",
            "#{answerId,jdbcType=BIGINT}, #{recommendId,jdbcType=BIGINT}, ",
            "#{recommendType,jdbcType=VARCHAR}, #{productId,jdbcType=BIGINT}, ",
            "#{productName,jdbcType=VARCHAR}, #{createBy,jdbcType=BIGINT}, ",
            "#{createDate,jdbcType=TIMESTAMP}, #{updateBy,jdbcType=BIGINT}, ",
            "#{updateDate,jdbcType=TIMESTAMP}, #{remarks,jdbcType=VARCHAR}, ",
            "#{delFlag,jdbcType=CHAR}, #{institutionId,jdbcType=BIGINT})"
    })
    int insert(BeautyConsultationOrderRecommendDetail record);

    @InsertProvider(type = BeautyConsultationOrderRecommendDetailSqlProvider.class, method = "insertSelective")
    int insertSelective(BeautyConsultationOrderRecommendDetail record);

    @Select({
            "select",
            "id, order_id, answer_id, recommend_id, recommend_type, product_id, product_name, ",
            "create_by, create_date, update_by, update_date, remarks, del_flag, institution_id",
            "from beauty_consultation_order_recommend_detail",
            "where id = #{id,jdbcType=BIGINT} and del_flag = '1'"
    })
    @Results({
            @Result(column = "id", property = "id", jdbcType = JdbcType.BIGINT, id = true),
            @Result(column = "order_id", property = "orderId", jdbcType = JdbcType.BIGINT),
            @Result(column = "answer_id", property = "answerId", jdbcType = JdbcType.BIGINT),
            @Result(column = "recommend_id", property = "recommendId", jdbcType = JdbcType.BIGINT),
            @Result(column = "recommend_type", property = "recommendType", jdbcType = JdbcType.VARCHAR),
            @Result(column = "product_id", property = "productId", jdbcType = JdbcType.BIGINT),
            @Result(column = "product_name", property = "productName", jdbcType = JdbcType.VARCHAR),
            @Result(column = "create_by", property = "createBy", jdbcType = JdbcType.BIGINT),
            @Result(column = "create_date", property = "createDate", jdbcType = JdbcType.TIMESTAMP),
            @Result(column = "update_by", property = "updateBy", jdbcType = JdbcType.BIGINT),
            @Result(column = "update_date", property = "updateDate", jdbcType = JdbcType.TIMESTAMP),
            @Result(column = "remarks", property = "remarks", jdbcType = JdbcType.VARCHAR),
            @Result(column = "del_flag", property = "delFlag", jdbcType = JdbcType.CHAR),
            @Result(column = "institution_id", property = "institutionId", jdbcType = JdbcType.BIGINT)
    })
    BeautyConsultationOrderRecommendDetail selectByPrimaryKey(Long id);

    @Select({
            "select",
            "id, order_id, answer_id, recommend_id, recommend_type, product_id, product_name, ",
            "create_by, create_date, update_by, update_date, remarks, del_flag, institution_id",
            "from beauty_consultation_order_recommend_detail",
            "where order_id = #{orderId} and del_flag = '1'"
    })
    @Results({
            @Result(column = "id", property = "id", jdbcType = JdbcType.BIGINT, id = true),
            @Result(column = "order_id", property = "orderId", jdbcType = JdbcType.BIGINT),
            @Result(column = "answer_id", property = "answerId", jdbcType = JdbcType.BIGINT),
            @Result(column = "recommend_id", property = "recommendId", jdbcType = JdbcType.BIGINT),
            @Result(column = "recommend_type", property = "recommendType", jdbcType = JdbcType.VARCHAR),
            @Result(column = "product_id", property = "productId", jdbcType = JdbcType.BIGINT),
            @Result(column = "product_name", property = "productName", jdbcType = JdbcType.VARCHAR),
            @Result(column = "create_by", property = "createBy", jdbcType = JdbcType.BIGINT),
            @Result(column = "create_date", property = "createDate", jdbcType = JdbcType.TIMESTAMP),
            @Result(column = "update_by", property = "updateBy", jdbcType = JdbcType.BIGINT),
            @Result(column = "update_date", property = "updateDate", jdbcType = JdbcType.TIMESTAMP),
            @Result(column = "remarks", property = "remarks", jdbcType = JdbcType.VARCHAR),
            @Result(column = "del_flag", property = "delFlag", jdbcType = JdbcType.CHAR),
            @Result(column = "institution_id", property = "institutionId", jdbcType = JdbcType.BIGINT)
    })
    List<BeautyConsultationOrderRecommendDetail> selectByOrderId(@Param("orderId") Long orderId);

    @UpdateProvider(type = BeautyConsultationOrderRecommendDetailSqlProvider.class, method = "updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(BeautyConsultationOrderRecommendDetail record);

    @Update({
            "update beauty_consultation_order_recommend_detail",
            "set order_id = #{orderId,jdbcType=BIGINT},",
            "answer_id = #{answerId,jdbcType=BIGINT},",
            "recommend_id = #{recommendId,jdbcType=BIGINT},",
            "recommend_type = #{recommendType,jdbcType=VARCHAR},",
            "product_id = #{productId,jdbcType=BIGINT},",
            "product_name = #{productName,jdbcType=VARCHAR},",
            "create_by = #{createBy,jdbcType=BIGINT},",
            "create_date = #{createDate,jdbcType=TIMESTAMP},",
            "update_by = #{updateBy,jdbcType=BIGINT},",
            "update_date = #{updateDate,jdbcType=TIMESTAMP},",
            "remarks = #{remarks,jdbcType=VARCHAR},",
            "del_flag = #{delFlag,jdbcType=CHAR},",
            "institution_id = #{institutionId,jdbcType=BIGINT}",
            "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(BeautyConsultationOrderRecommendDetail record);
}